import { BasicTable, FormSchema, useTable, BasicColumn } from "@/components/Table";
import { useTranslation } from "react-i18next";
import { outpatientsPagenew } from "@/api/MedicalExamination";
import moment from "moment";
const index = () => {
	const { t } = useTranslation();
	const searchFormSchema: FormSchema[] = [
		{
			label: t("felix_ui.dt_date"),
			field: "rxDtime",
			component: "RangePicker",
			componentProps: {
				showTime: {
					defaultValue: [moment("00:00:00", "DD-MM-YYYY"), moment("23:59:59", "DD-MM-YYYY")]
				}
			}
		},
		{
			label: t("kevin_ui.patient_id"),
			field: "patientId",
			component: "Input"
		},
		{
			label: t("kevin_ui.full_name"),
			field: "fullName",
			component: "Input"
		},
		{
			label: t("kevin_ui.birth_year"),
			field: "birthday",
			component: "Input"
		},
		{
			label: t("felix_ui.age"),
			field: "age",
			component: "Input"
		},
		{
			label: t("felix_ui.gender"),
			field: "gender",
			component: "Input"
		},
		{
			label: t("felix_ui.house_number"),
			field: "homeNumber",
			component: "Input"
		},
		{
			label: t("felix_ui.village_street"),
			field: "street",
			component: "Input"
		},
		{
			label: t("felix_ui.occupation"),
			field: "Occupation",
			component: "Input"
		},
		{
			label: t("felix_ui.province_city"),
			field: "Province",
			component: "Input"
		},
		{
			label: t("felix_ui.district"),
			field: "District",
			component: "Input"
		},
		{
			label: t("felix_ui.districtc_ward_commune"),
			field: "commune",
			component: "Input"
		},
		{
			label: t("felix_ui.ethnicity"),
			field: "Ethnicity",
			component: "Input"
		},
		{
			label: t("felix_ui.beneficiary"),
			field: "Beneficiary",
			component: "Input"
		},
		{
			label: t("felix_ui.card_numb"),
			field: "Card Number",
			component: "Input"
		},
		{
			label: t("felix_ui.doctor"),
			field: "Doctor",
			component: "Select"
		},
		{
			label: t("kevin_ui.home_phone"),
			field: "homePhone",
			component: "Input"
		},
		{
			label: t("kevin_ui.payment"),
			field: "payment",
			component: "Input"
		},
		{
			label: t("felix_ui.grp_email"),
			field: "email",
			component: "Input"
		},
		{
			label: t("felix_ui.transferDocument"),
			field: "transferDocument",
			component: "Select"
		},
		{
			field: "isOtherHis",
			component: "CheckboxGroup",
			componentProps: {
				options: [{ label: "Registration for Treatment at Another Hospital", value: "1" }]
			},
			itemProps: {
				wrapperCol: { span: 12, offset: 8 }
			}
		},
		{
			label: t("kevin_ui.salary"),
			field: "salary",
			component: "Input"
		}
	];
	const columns: BasicColumn[] = [
		{
			title: t("felix_ui.numb_of_sheet"),
			dataIndex: "opNo"
		},
		{
			title: t("felix_ui.pat_cardno"),
			dataIndex: "patCardno"
		},
		{
			title: t("felix_ui.maternal_care"),
			dataIndex: "maternalCare"
		},
		{
			title: t("felix_ui.full_name"),
			dataIndex: "fullName"
		},
		{
			title: t("felix_ui.birthday"),
			dataIndex: "birthday"
		},
		{
			title: t("felix_ui.gender"),
			dataIndex: "gender"
		},

		{
			title: t("felix_ui.house_number"),
			dataIndex: "addrHouseno"
		},
		{
			title: t("felix_ui.districtc_ward_commune"),
			dataIndex: "addrCommune"
		},
		{
			title: t("felix_ui.district"),
			dataIndex: "addrDistrict"
		},
		{
			title: t("felix_ui.province_city"),
			dataIndex: "province"
		}
	];
	let util = async () => {
		let arr: any = [];
		await outpatientsPagenew({}).then(res => {
			arr = res.list.map((item: any) => {
				return {
					...item,
					...item.patients,
					...item.admissions
				};
			});
		});
		return arr;
	};
	const [registerTable] = useTable({
		api: util,
		columns,
		formConfig: {
			labelWidth: 120,
			labelWrap: true,
			schemas: searchFormSchema,
			showActionButtonGroup: true,
			showAdvancedButton: false,
			baseColProps: { span: 6 }
		},
		useSearchForm: true
	});

	return (
		<div className="page">
			{/* <div className="page-content"> */}
			<BasicTable register={registerTable}></BasicTable>
			{/* </div> */}
		</div>
	);
};
export default index;
